package Service.Impl;

import Dao.ResourceCategoryMapper;
import Dao.ResourceMapper;
import domain.Resource;
import domain.ResourceCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import Service.ResourceCategoryService;


import java.util.Date;
import java.util.List;

@Service
public class ResourceCategoryServiceImpl implements ResourceCategoryService {

    @Autowired
    private ResourceCategoryMapper resourceMapper;

    /*
            资源分类表的查询
     */

    @Override
    public List<ResourceCategory> findAllResourceCategory() {
        List<ResourceCategory> resourceCategory = resourceMapper.findAllResourceCategory();
        return resourceCategory;
    }

    /*
        添加&修改资源分类表
    */

    @Override
    public void saveResourceCategory(ResourceCategory resourceCategory) {

        // 更新信息
        Date date = new Date();
        resourceCategory.setCreatedTime(date);
        resourceCategory.setUpdatedTime(date);

        resourceCategory.setCreatedBy("mengjie");
        resourceCategory.setUpdatedBy("mengjie");

        resourceMapper.saveResourceCategory(resourceCategory);
    }

    @Override
    public void updateResourceCategory(ResourceCategory resourceCategory) {

        // 更新信息
        Date date = new Date();
        resourceCategory.setUpdatedTime(date);

        resourceMapper.updateResourceCategory(resourceCategory);
    }


    /*
        删除资源分类表信息
     */
    @Override
    public void deleteResourceCategory(int id) {

        resourceMapper.deleteResourceCategory(id);

    }
}
